using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Resources;
using System.Globalization;
using System.Reflection;

namespace AKS_Size_Utility
{
    public partial class BrowserCheck : Form
    {        
        RegistryKey key;

        string skey = "";

        public BrowserCheck()
        {
            InitializeComponent();

            // Attempt to open the key
            key = Registry.LocalMachine.OpenSubKey("Software\\HISC\\Size\\BrowserMsg");

            // If the return value is null, the key doesn't exist
            if (key == null)
            {
                // The key doesn't exist; create it / open it
                key = Registry.LocalMachine.CreateSubKey("Software\\HISC\\Size");
                key.SetValue("BrowserMsg", "0");
            }

            // Attempt to retrieve the value X; if null is returned, the value
            // doesn't exist in the registry.
            if (key.GetValue("BrowserMsg") != null)
            {
                skey = key.GetValue("BrowserMsg").ToString();
            }
            else
            {
                key.SetValue("BrowserMsg", "0");
            }

            ResourceManager rm = new ResourceManager("AKS_Size_Utility.Resource1", Assembly.GetExecutingAssembly());

            this.Text = rm.GetString("BrowserCheck");
            lblWouldYouLikeToDisplayThisList.Text = rm.GetString("lblWouldYouLikeToDisplayThisList");
            lblInYourDefaultBrowser.Text = rm.GetString("lblInYourDefaultBrowser");
            btnYes.Text = rm.GetString("BrowserCheckbtnYes");
            btnNo.Text = rm.GetString("BrowserCheckbtnNo");
            chbxDisplayInBrowser.Text = rm.GetString("chbxDisplayInBrowser");
        }

        private void btnYes_Click(object sender, EventArgs e)
        {
            if (chbxDisplayInBrowser.Checked)
            {
                key.SetValue("BrowserMsg", "1");
            }
            else
            {
                key.SetValue("BrowserMsg", "0");
            }
        }

        private void btnNo_Click(object sender, EventArgs e)
        {

        }
    }
}